package com.nitty.cash.loop.ui.adapter

import androidx.recyclerview.widget.RecyclerView
import com.lib.common.adapter.CommonRecyclerViewAdapter
import com.lib.common.adapter.CommonViewHolderHelper
import com.nitty.cash.loop.R
import org.json.JSONObject

/**
 * NittyCash
 * @Author wwdeng
 * @CreateTime: 2024/11/18 16:42
 * @Annotation：客服适配器
 */
class NittyCustomerAdapter(recyclerView: RecyclerView?) : CommonRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.dialog_customer_item) {
    override fun setItemChildListener(helper: CommonViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.btnCustomer) //拨号、复制
    }

    override fun fillData(helper: CommonViewHolderHelper, position: Int, model: JSONObject) {
        helper.setText(R.id.textCustomerValue,model.optString("value"))
        val imgCustomerFun = helper.getImageView(R.id.imgCustomerFun)
        when(model.optString("type")){
            "MOBILE" -> {//电话
                helper.setText(R.id.textCustomerTitle,String.format(mContext.getString(R.string.customer_mobile_title),"${position +1}"))
                helper.setText(R.id.textCustomerFun,mContext.getString(R.string.customer_mobile_dial))
                imgCustomerFun.setImageResource(R.mipmap.nitty_customer_mobile_call)
            }
            else -> {//邮箱
                helper.setText(R.id.textCustomerTitle,mContext.getString(R.string.customer_email_title))
                helper.setText(R.id.textCustomerFun,mContext.getString(R.string.customer_email_copy))
                imgCustomerFun.setImageResource(R.mipmap.nitty_customer_email_copy)
            }
        }
    }
}